-
Notifications
You must be signed in to change notification settings - Fork 368
Update namespace & topic admin methods to return nil if unset #1433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
test failure: |
75a181a to
c2e4deb
Compare
c2e4deb to
89e8bd6
Compare
|
@lhotari Thanks, fixed up the test issues. I needed to change a bit more in the client package that should be reviewed carefully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the behavior of topic and namespace policy getter methods to return nil when policies are not configured at the topic/namespace level, rather than returning default/zero values. This is accomplished by introducing a new GetBodyWithContext method and decodeJSONWithBody helper that detect empty HTTP response bodies.
Key Changes
- Added
GetBodyWithContextanddecodeJSONWithBodyfunctions to REST client for detecting empty response bodies - Updated policy getter methods to return
nilwhen policies are not configured (empty response) - Updated tests to expect
nilvalues instead of zero-value structs when policies are removed or not configured
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pulsaradmin/pkg/rest/client.go | Added GetBodyWithContext method and decodeJSONWithBody helper to detect and return empty response bodies |
| pulsaradmin/pkg/admin/topic.go | Updated policy getter methods and documentation to return nil when policies are not configured |
| pulsaradmin/pkg/admin/topic_test.go | Updated tests to expect nil instead of zero values when policies are not configured |
| pulsaradmin/pkg/admin/namespace.go | Updated namespace policy getter methods and documentation to return nil when policies are not configured |
| pulsaradmin/pkg/admin/namespace_test.go | Added comprehensive tests for namespace policies expecting nil for unconfigured policies |
Comments suppressed due to low confidence (1)
pulsaradmin/pkg/rest/client.go:220
- Line 220 returns
nil, errbuterris undefined at this point if theelse if !decodeblock was entered but neither thefile != nilnor theelsebranch returned. This will cause a compilation error or return an undefined error. Should returnnil, nilinstead.
return nil, err
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
crossoverJie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #1431
Motivation
For the namespace / topic admin methods that return a pointer, explicitly return nil if the method isn't set (API returns empty body)
Modifications
GetBodyWithContextthat returns body & errorVerifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation